// 配送订单相关类型定义

// 地点信息
export interface LocationInfo {
    locationId: string;         // 地点ID
    name: string;               // 地点名称
    detailedAddress: string;    // 详细地址
    type: string;               // 地点类型
    note: string | null;        // 备注
    latitude: number | null;    // 纬度
    longitude: number | null;    // 经度
    isPickupPoint: boolean;      // 是否取货点
    contactPhone: string | null; // 联系方式
    businessHours: string | null; // 营业时间
    status: number;              // 状态
}

// 创建配送订单请求参数
export interface CreateDeliveryOrderRequest {
    recipientId: string;        // 收件人姓名
    phone: string;             // 联系方式
    pickupAddress: string;     // 取货地点ID
    pickupDetails: string;     // 取货详情
    deliveryAddress: string;   // 送达地点ID
    deliverDetails: string;    // 送达详情
    appointmentTime: string;   // 预约时间
    timestamp?: number;        // 提交时间戳
}

// 创建配送订单响应
export interface CreateDeliveryOrderResponse {
    success: boolean;
    message: string;
    data?: {
        orderId: string;
        status: string;
        createTime: string;
    };
}

// 配送订单信息
export interface DeliveryOrder {
    id: string;
    recipientId: string;
    phone: string;
    pickupAddress: string;
    pickupDetails: string;
    deliveryAddress: string;
    deliverDetails: string;
    appointmentTime: string;
    status: 'pending' | 'in_progress' | 'delivered' | 'cancelled';
    createTime: string;
    updateTime: string;
    deliveryPersonnel?: string;
    pickupCode?: string;
}

// 获取订单列表请求参数
export interface GetOrdersRequest {
    page?: number;
    pageSize?: number;
    status?: string;
    recipientId?: string;
}

// 获取订单列表响应
export interface GetOrdersResponse {
    success: boolean;
    message: string;
    data?: {
        orders: DeliveryOrder[];
        total: number;
        page: number;
        pageSize: number;
    };
}

// 更新订单状态请求参数
export interface UpdateOrderStatusRequest {
    orderId: string;
    status: string;
    deliveryPersonnel?: string;
    notes?: string;
}

// 更新订单状态响应
export interface UpdateOrderStatusResponse {
    success: boolean;
    message: string;
    data?: DeliveryOrder;
}

// 管理员统计相关接口
export interface AdminStatsResponse {
    success: boolean;
    message: string;
    data?: {
        todayStats: {
            totalOrders: number;
            completedOrders: number;
            pendingOrders: number;
        };
        totalStats: {
            totalOrders: number;
            completedOrders: number;
            pendingOrders: number;
        };
        mostPopularPickup: {
            name: string;
            count: number;
        };
        mostPopularDelivery: {
            name: string;
            count: number;
        };
        dormitoryStats: DormitoryStats[];
    };
}

export interface DormitoryStats {
    name: string;
    todayOrders: number;
    totalOrders: number;
    pickupOrders: number;
    deliveryOrders: number;
    completionRate: number;
}
